import DialogManager from "./Dialog/Manager";
import SceneManager from "./Scene/Manager";

class Director {
    constructor () {}

    init () {
        DialogManager.init();
        SceneManager.init();

        Laya.Dialog.manager = DialogManager;
        // for(let i of ["open", "load", "_onSceneLoaded", "close", "closeAll", "destroy", "setLoadingPage", "showLoadingPage", "_showLoading", "_hideLoading", "hideLoadingPage", "_root", "_loadPage"]){
        //     delete Laya.Scene[i];
        // }
        delete Laya.Scene.open;
        delete Laya.Scene.load;
        delete Laya.Scene._onSceneLoaded;
        delete Laya.Scene.close;
        delete Laya.Scene.closeAll;
        delete Laya.Scene.destroy;
        delete Laya.Scene.setLoadingPage;
        delete Laya.Scene.showLoadingPage;
        delete Laya.Scene._showLoading;
        delete Laya.Scene._hideLoading;
        delete Laya.Scene.hideLoadingPage;
        delete Laya.Scene._root;
        delete Laya.Scene._loadPage;

        Laya.stage.on(Laya.Event.RESIZE, this, this._onResize);
    }

    _onResize () {
        DialogManager._onResize();
        SceneManager._onResize();
    }

//#region Scene相关方法
    runScene (urlOrClass, args = null) {
        SceneManager.open(urlOrClass, args);
    }

    getScene(){
        return SceneManager.runningScene;
    }

    setLoadingPageForScene (page) {
        // SceneManager.setLoadingPage(page);
    }
//#endregion

//#region Dialog相关方法
    openDialog(urlOrClass, args = null, config = {}){
        DialogManager.open(urlOrClass, args, config);
    }

    closeAllDialog(){
        // DialogManager.closeAll();
    }
    
    closeDialogByName(name){
        // DialogManager.closeDialogByName(name);
    }
    
    closeDialogsByGroup(group){
        // DialogManager.closeDialogsByGroup(group);
    }
    
    getDialogByName(name){
        // return DialogManager.getDialogByName(name);
    }
    
    getDialogByGroup(group){
        // return DialogManager.getDialogsByGroup(group);
    }

    setLoadingPageForDialog (page) {
        
    }
//#endregion

//#region 其他导演类方法，待完成
    //获取上一帧的增量时间。
    getDeltaTime(){

    }
    //获取 游戏 启动以来游戏运行的总帧数。
    getTotalFrames(){
        return Laya.stage.getTimeFromFrameStart();
    }
    //暂停正在运行的场景，该暂停只会停止游戏逻辑执行，但是不会停止渲染和 UI 响应。
    pause(){

    }
    //恢复暂停场景的游戏逻辑，如果当前场景没有暂停将没任何事情发生。
    resume(){

    }
    //是否处于暂停状态。
    get isPaused(){
        return false;
    }
//#endregion
}
 
export default new Director;